package com.tutucms.service.admin.configuration;

import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @title:
 * @author: wangxudong
 * @date: 2019/6/17 11:42
 * @version: 1.0
 * @modified :
 */
@Data
@Configuration
@ConfigurationProperties(prefix = "app.ali.alipay")
public class AliPayConfig {

    private static final String CHARSET = "UTF-8";

    private String gateway;
    private String appId;
    private String appPrivateKey;
    private String publicKey;
    private String encryptType;
    private String notifyUrl;
    private String returnUrl;

    @Bean
    public AlipayClient alipayClient() {
        AlipayClient alipayClient = new DefaultAlipayClient(gateway, appId, appPrivateKey, "json", CHARSET,
                publicKey, encryptType);

        return alipayClient;
    }
}
